package opera;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        System.out.println("请输入要查找的图书名：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();

        int currentSize = booklist.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getBook(i);
            if(book.getName().equals(name)){
                System.out.println(book);
                return;
            }
        }
        System.out.println("很遗憾未找到该书！");

    }
}
